<template>
    <div>
        <h2>管理员登陆(医生)</h2>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td align="right">账号</td>
                    <td>
                        <input type="text" v-model="info.username"></input>
                    </td>
                </tr>
                <tr>
                    <td align="right">密码</td>
                    <td>
                         <input type="password" v-model="info.userpwd"></input>
                    </td>
                </tr>
                <tr>
                    <td align="right"></td>
                    <td>
                        <input type="button" value="登陆" class="btn btn-primary" @click="login"></input>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from "axios";
import moment from "moment";
import {ref,reactive,onMounted} from "vue"
import {useRoute,useRouter} from "vue-router"
import {useStore} from "@/stores/user"

const route = useRoute();
const router = useRouter();
const abc = useStore();

let info:any = reactive({
    username:'',
    userpwd:''
})

const login=()=>{
    if(info.username==""){
        alert('账号不能为空');
        return
    }
    if(info.userpwd==""){
        alert('密码不能为空');
        return
    }
    axios({
        url:'/api/YeHotels/Login',
        method:'get',
        params:info
    })
    .then(res=>{
        console.log(res);
        if(res.data==-1){
            alert('没有该账号');
            return;
        }
        if(res.data==-2){
            alert('密码错误');
            return;
        }
        alert('登陆成功');
        abc.userinfo = res.data;
        router.push("/sirShow")
        return;
    })
    .catch(err=>{
        console.log(err);
        
    })
}
</script>

<style scoped>

</style>